@@ -22,23 +22,22 @@ class ApplicationController < ActionController::Base |
||
| 22 | 22 |
@config = Info.first |
| 23 | 23 |
if cookies[:avalanche_locale] && I18n.available_locales.include?(cookies[:avalanche_locale].to_sym) |
| 24 | 24 |
l = cookies[:avalanche_locale].to_sym |
| 25 |
- else |
|
| 26 |
- begin |
|
| 27 |
- |
|
| 28 |
- http_accept_language = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
|
|
| 29 |
- if http_accept_language != '' |
|
| 30 |
- ["pt-BR", "pt-br", "pt", "br"].include?(http_accept_language) ? l = :"pt-BR" : l = @config.default_language |
|
| 31 |
- |
|
| 32 |
- else |
|
| 33 |
- l = @config.default_language # use default locale if cannot retrieve this info |
|
| 34 |
- end |
|
| 35 |
- rescue |
|
| 36 |
- l = @config.default_language |
|
| 37 |
- ensure |
|
| 38 |
- cookies.permanent[:avalanche_locale] = l |
|
| 25 |
+ else |
|
| 26 |
+ begin |
|
| 27 |
+ http_accept_language = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
|
|
| 28 |
+ if http_accept_language != '' |
|
| 29 |
+ ["pt-BR", "pt-br", "pt", "br"].include?(http_accept_language) ? l = :"pt-BR" : l = @config.default_language |
|
| 30 |
+ |
|
| 31 |
+ else |
|
| 32 |
+ l = @config.default_language # use default locale if cannot retrieve this info |
|
| 39 | 33 |
end |
| 34 |
+ rescue |
|
| 35 |
+ l = @config.default_language |
|
| 36 |
+ ensure |
|
| 37 |
+ cookies.permanent[:avalanche_locale] = l |
|
| 40 | 38 |
end |
| 41 |
- I18n.locale = l |
|
| 39 |
+ end |
|
| 40 |
+ I18n.locale = l |
|
| 42 | 41 |
end |
| 43 | 42 |
|
| 44 | 43 |
def analytics |
@@ -33,9 +33,7 @@ class User < ActiveRecord::Base |
||
| 33 | 33 |
@analytics = Analytics.new(self.full_name) |
| 34 | 34 |
@analytics.track_user_registration(self) |
| 35 | 35 |
# Save user current language |
| 36 |
- if !Rails.env.test? |
|
| 37 |
- self.uplade(language: cookies[:avalanche_locale]) |
|
| 38 |
- end |
|
| 36 |
+ self.update(language: I18n.locale.to_s) |
|
| 39 | 37 |
end |
| 40 | 38 |
|
| 41 | 39 |
def incomplete_step_count |